<?php
    $canProceed = true;
    if(isset($_POST['titel']) && isset($_POST['content']) &&
            $_POST['titel'] != '' && $_POST['content'] != '')
    {
        $titel   = $_POST['titel'];
        $content = $_POST['content'];
    }
    else
    {
        $canProceed = false;
    }
    
    require '../../../modules/MessageManager/MessageManager.php';
    if ($canProceed)
    {
        $timestamp = time();
    
        $url = '../../../views/' . $titel . '_' . date('d-m-Y', $timestamp) . '.html';
    
        $date = date('Y.m.d - H:i:s'); 
   
        require '../../../modules/PageManager/Pagemanager.php';
        $page    = new Page($titel, $content, $url, 1);
        $page->setCreationDate($date);
        $pageMan = new PageManager();
        $pageMan->createPage($page);
        MessageManager::writeMessage('Seite erstellt', 0);
    }
    else
    {
        MessageManager::writeMessage('Keine Daten!', 2);
    }
?>